<template>
  <!-- 猜你喜欢 模板 -->
  <div>
    <div v-if="wideGoods.length">
      <div class="like-box clearfix">
        <div class="like-item" v-for="(val, index) in wideGoods[0].goodsList" :key='index'>
          <div class="l_img"><img v-lazy="val.img" alt=""></div>
          <div class="l_title">
            <p :title="val.goodsName">{{val.goodsName}}</p>
            <p>￥{{val.goodsPrice}}</p>
          </div>
          <button @click="editItem('you_like')" v-if="index >= 4 ? index == 4 : index == wideGoods[0].goodsList.length-1">编辑</button>
        </div>
      </div>
    </div>
    <div v-else>
      <div class="like-box clearfix">
        <div class="like-item" v-for="(val, index) in arr" :key='index'>
          <button @click="editItem('you_like')" v-if="index == 4">编辑</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: {
    floorId: String,
    wideGoods: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      arr: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
    }
  },
  methods: {
    editItem() {
      this.$emit('on-edit', this.floorId, 'you_like', '')
    }
  }
}
</script>

<style lang='scss' scoped>
@import '../../../scss/_var.scss';
.like-box {
  width: 100%;
  .like-item {
    width: 109px;
    height: 120px;
    margin-top: 10px;
    float: left;
    margin-right: 5px;
    background: $bg-gray;
    position: relative;
    &:nth-child(5n+5) {
      margin-right: 0;
    }
    .l_img {
      width: 100%;
      height: 80px;
    }
    .l_title {
      padding: 0 5px;
      & > p {
        width: 100%;
        height: 20px;
        line-height: 20xp;
        overflow: hidden;
      }
      & > p:last-child {
        color: $color-main;
      }
    }
  }
}
button {
  width: 40px;
  height: 20px;
  border-radius: 10px;
  background: $color-main;
  position: absolute;
  top: 10px;
  right: 10px;
  color: #fff;
  font-size: 12px;
}
</style>
